package main.scala.KNNalgorithm

import org.apache.spark.rdd.RDD
import org.apache.spark.sql.SparkSession

import scala.collection.mutable

object test {
  def main(args: Array[String]): Unit = {
//    val nodes: Seq[Seq[Double]] = {
//      Seq(Seq(2, 3), Seq(5, 4), Seq(9, 6), Seq(4, 7), Seq(8, 1), Seq(7, 2))
//
//    }
//
//
//    nodes.foreach(x=>{val f= x (1)
//    println(f)})
//
//    //  test for sortBy function
//    val sorted = nodes.sortBy(x => x(1))
//    sorted.foreach(println)
//    //  test for slice function
//    println("==================")
//    sorted.slice(0,2).foreach(println)
//
//
//    val nodes2 = nodes.slice(90,130)
//    nodes2 match {
//      case Nil => println("hello nill")
//      case _ => println("not null",nodes2)
//    }


    val spark = SparkSession.builder()
      .appName(this.getClass.getName)
      .master("local[*]")
      .getOrCreate()
    val value: RDD[Seq[Double]] = spark.sparkContext.textFile("data/your_graph_path_EXA.csv")
      .map(x => x.split(",").toSeq)
      .map(x => (x.map(y => y.toDouble)))
    var seqs:Seq[Seq[Double]] =Seq()
//    var c = mutable.Seq[Double](1,2,3)
    var c= Seq[Seq[Double]](Seq(1,2,3))
    var x: Seq[Double] = Seq(1,2,3)
    var c2: Seq[Seq[Double]] = Seq[Seq[Double]](Seq(1,2,3))
//   var d: Seq[Seq[Double]] = seqs ++: c
   seqs  = seqs ++: c
    print(seqs)
    seqs=  seqs ++: c2
println("======================")
    print(seqs)
  }

}
